package com.xuecheng.content.convert;

import com.xuecheng.api.content.teacher.CourseTeacherDTO;
import com.xuecheng.api.content.teacher.CourseTeacherVO;
import com.xuecheng.api.content.teachplan.dto.TeachplanDTO;
import com.xuecheng.api.content.teachplan.dto.TeachplanMediaDTO;
import com.xuecheng.api.content.teachplan.vo.TeachplanVO;
import com.xuecheng.content.entity.CourseTeacher;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.TeachplanMedia;
import com.xuecheng.content.entity.ext.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface TeachplanConvert {

    TeachplanConvert INSTANCE = Mappers.getMapper(TeachplanConvert.class);


    @Mappings({
            @Mapping(source = "id", target = "teachPlanId"),
            @Mapping(source = "childrenNodes", target = "teachPlanTreeNodes")
    })
    TeachplanDTO node2dto(TeachplanNode teachplanNode);

    @Mapping(source = "teachPlanId", target = "id")
    Teachplan dto2entity(TeachplanDTO dto);

    @Mapping(source = "id", target = "teachPlanId")
    TeachplanDTO entity2dto(Teachplan teachplan);

    TeachplanDTO vo2dto(TeachplanVO teachplanVO);

    TeachplanMediaDTO entitytwo2dto(TeachplanMedia teachplan);

    //教师用
    @Mapping(source = "id", target = "courseTeacherId")
    CourseTeacherDTO entityTwo2Dto(CourseTeacher teacher);

    @Mapping(source = "courseTeacherId", target = "id")
    CourseTeacher DtoTwo2Dto(CourseTeacherDTO dto);


    CourseTeacherDTO vo2Dto(CourseTeacherVO vo);


    List<TeachplanDTO> nodes2dtos(List<TeachplanNode> nodes);

    /**
     * 集合数据映射是依赖于单个的数据映射方法
     *
     *
     */


    List<CourseTeacherDTO> entity2dtos(List<CourseTeacher> nodes);
}